/**
 * Created by yongqiang.ren on 2016/12/7.
 */

import { environments } from './constants';

const env = process.env.NODE_ENV || 'development';

const defaultDatabaseUrl = {
  [environments.TEST.value]: 'mysql://root:admin@mysql:3306',
  [environments.DEV.value]: 'mysql://root:admin@localhost:3306',
  [environments.ALPHA.value]: 'mysql://root:admin@10.0.1.7:3306',
  [environments.BETA.value]: 'mysql://gc_user:Vf84DzVqoU4oG@gc-alpha.caxw2fctblkd.rds.cn-north-1.amazonaws.com.cn:3306',
  [environments.PROD.value]: 'mysql://gc_user:asdfiowS_8sdf@gc-prod.caxw2fctblkd.rds.cn-north-1.amazonaws.com.cn:3306',
};

const defaultJwtSecret = {
  [environments.TEST.value]: '0123456789ABCDEF',
  [environments.DEV.value]: 'sdfasdfssdfsdfs',
  [environments.ALPHA.value]: 'Rxdfdsf)7y%jaH',
  [environments.BETA.value]: 'Dxdfsdfo)70ysif',
  [environments.PROD.value]: 'D6JzDpk)7y%jaH',
};

const uploadBucketName = {
  [environments.TEST.value]: 'gc-attachment',
  [environments.DEV.value]: 'gc-attachment',
  [environments.ALPHA.value]: 'gc-attachment',
  [environments.BETA.value]: 'gc-attachment',
  [environments.PROD.value]: 'gc-attachment-prod',
};

const formSuggestionServiceUrl = {
  [environments.TEST.value]: 'http://form-suggestion:6000',
  [environments.DEV.value]: 'http://localhost:6000',
  [environments.BETA.value]: 'http://10.0.1.134:6000',
  [environments.PROD.value]: 'http://10.0.1.134:6000',
};

const config = {
  env,
  server: {
    port: 9090,
  },
  auth: {
    jwt: {
      secret: defaultJwtSecret[env],
    },
    jpush: {
      appKey: 'a4523470808efb1644b3cc5e',
      secret: 'dca50f80ae85ca5ede1ce014',
    },
    leanCloud: {
      appId: 'S2up3kizplLoGErpcSjra10B-gzGzoHsz',
      appKey: '238N6SOIp4vL7Bu3l2mJfNUp',
    },
  },
  statsd: {
    host: '10.0.1.244',
    port: 8125,
  },
  log: {
    path: './logs',
  },
  mysql: {
    databaseUrl: process.env.DATABASE_URL || defaultDatabaseUrl[env],
  },
  formSuggestion: {
    Url: process.env.formSuggestionUrl || formSuggestionServiceUrl[env],
  },
  s3: {
    key: 'AKIAP26FY7CHDSZKCJGQ',
    secret: '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',
    region: 'cn-north-1',
    bucket: uploadBucketName[env] || 'gc-attachment',
  },
  mailService: {
    exportLog: {
      url: 'http://exportaas.blacklake.tech:15000/',
    },
  },
};

module.exports = config;
